package com.im.web.core.service;

import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/** @author gongym */
@Component
@Transactional(rollbackFor = Exception.class)
public class BaseService {
  @SuppressWarnings("SpringJavaAutowiredFieldsWarningInspection")
  @Autowired
  @PersistenceContext
  protected EntityManager entityManager;

  protected JPAQueryFactory queryFactory;

  @PostConstruct
  public void init() {
    queryFactory = new JPAQueryFactory(entityManager);
  }
}
